﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using System.Linq;
using System.Xml.Linq;

namespace conti.maurizio._4BI.Figure
{
    /// <summary>
    /// Logica di interazione per MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            button1.Content = "Hello WPF 2";
        }

        private void RegularPolygon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            button1.Content = "Hello STAR!";

            //XElement xmlW = new XElement
            //    (
            //        "figure", 
            //            new XElement( "quadrato", new XAttribute("nome", "quadrato"), new XAttribute("lato", "10") ),
            //            new XElement( "cerchio"),
            //            new XElement("rettangolo"),
            //            new XElement( "rettangolo" )
            //    );

            //xmlW.Save("Dati.xml");

            XElement xmlR = XElement.Load("dati.xml");

            var righe = xmlR.Elements();
            
            foreach (XElement elemento in righe)
            {
                Console.WriteLine( elemento.Attribute("nome") );

                if (elemento.HasElements)
                {
                    string s = elemento.Element("immagine").Attribute("nomeFile").Value;
                    Console.WriteLine( " - ha una immagine: " + s );
                }
            }

        }

    }
}
